#ifndef  MYGTSTOOLS
#define  MYGTSTOOLS
#include <cmath>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include "utils.h"

using std::vector;
using std::string;
using std::ifstream;
using std::cerr;
using std::cout;
using std::endl;

#include "gts.h"

#ifndef PI
#  define PI 3.14159265359
#endif

class CGTSRead{

 public:
  CGTSRead(string fname):gts_filename(fname){verbose = FALSE;
  if(!Init())
    {
      cerr<<"ERROR loading Surface GTS file from:  \n"<< gts_filename<<endl;
      exit(-13);
    } 
  }
  ~CGTSRead(){FreeMem();}
  void FreeMem(){}
  void  IsOnePointInside(GtsSurface * s, gdouble x,gdouble y, gdouble z);
  void  IsPointsInside(GtsSurface * s);
  //  vector<int> GetPointsInside(GtsSurface * s, std::vector< tagCoord<float> > Pos);
  vector<int> GetPointsInside(float* Pos, int np);
  bool Init();
  void Stats();
  void ShowVertexes();
  static void write_vertex (GtsVertex * v, guint * nv)
    {
      printf ("  %g %g %g\n",
	      GTS_POINT (v)->x, GTS_POINT (v)->y, GTS_POINT (v)->z); 
      GTS_OBJECT (v)->reserved = GUINT_TO_POINTER ((*nv)++);
    }

 protected:
  FILE *gts_file;
  FILE *id_file;
  string gts_filename;
  GtsSurface * s;
  GtsFile * fp;
  gboolean verbose;
};
#endif
